<?php

/*---增删改查用户数据信息-----*/
namespace app\member\controller\db;
use app\member\model\Member as MemberModel;

use think\Controller;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\facade\Log;

class Member extends Controller
{
    public function selectAll(){
        $data = new MemberModel();
        try {
            $data = $data->selectOrFail();
        } catch (DataNotFoundException $e) {
        } catch (ModelNotFoundException $e) {
        } catch (DbException $e) {
            Log::warning("查询数据库错误");
        }
        return json($data);
    }


    public function selectByName($account){
        try {
            $data = MemberModel::where("member_name", $account)->findOrEmpty();
            if(!$data->toArray()){
                return false;
            }else{
                return $data->toArray();
            }
        } catch (DataNotFoundException $e) {
        } catch (ModelNotFoundException $e) {
        } catch (DbException $e) {
            Log::warning("查询数据库错误");
        }
        return false;
    }


    public function selectByEmail($email){
        try {
            $data = MemberModel::where("member_email", $email)->findOrEmpty();
            if(!$data->toArray()){
                return false;
            }else{
                return $data->toArray();
            }
        } catch (DataNotFoundException $e) {
        } catch (ModelNotFoundException $e) {
        } catch (DbException $e) {
            Log::warning("查询数据库错误");
        }
        return false;
    }
}